//Created by: Huiyi

Ext.define('MajorProjectSenchaTouch.view.LibraryVideosModule.LibraryVideosListItem', {
    extend: 'Ext.dataview.component.DataItem',
    xtype : 'libraryvideosListItem',
    alias: 'widget.libraryvideosListItem',
    requires:[
    'Ext.Panel',
    'Ext.Button'
    ],
    config: {
       	
		videoButton:{
		pressedCls:'videoBtnClicked',
		text: '   ',
        iconAlign: 'right',
        iconCls: 'code3',
        iconMask: true
        },
		
	//--------------------------------------------------------------------------------------------------------------
        dataMap: {            
            getVideoButton: {
                setText: 'title'
            }
            
        }
    },
    
    //apply methods----------------------------------------------------------------------------------
    
	
	 applyVideoButton: function(config) {
        return Ext.factory(config, Ext.Button, this.getVideoButton());
    },
    updateVideoButton: function(newVideoButton, oldVideoButton) {
		
		
        if (oldVideoButton) {
            this.remove(oldVideoButton);
        }

      if  (newVideoButton) {
            newVideoButton.on('tap', this.onVideoButtonTap, this);
            this.add(newVideoButton);
           
		}
    },
	
	//Listeners-----------------------------------------------------------------------------------------------

    onVideoButtonTap: function(button, e){
			var record = this.getRecord();
			
			window.open(record.get("url"));
       
    },
	
});
